#ifndef _PORTING_TDA10025_TDS_H_
#define _PORTING_TDA10025_TDS_H_

#include <sys_config.h>
#include <types.h>
#include <retcode.h>
#include <hld/nim/nim_dev.h>
#include <hld/nim/nim_tuner.h>
#include <osal/osal.h> 
#include <api/libc/alloc.h>
#include <api/libc/printf.h>
#include <api/libc/string.h>
#include <hal/hal_gpio.h>
#include <bus/i2c/i2c.h>
#include <hld/hld_dev.h>
#include <hld/nim/nim.h>
#include <bus/tsi/tsi.h>

#if 0
#define TDA10025_PRINTF nim_print   //(x...) printk(KERN_INFO x)
#else
#define TDA10025_PRINTF(...) do{}while(0)
#endif



#define nim_print  		libc_printf


#define comm_malloc 			MALLOC
#define comm_memset				MEMSET
#define comm_free				FREE
#define comm_delay				nim_comm_delay
#define comm_sleep				osal_task_sleep
#define comm_memcpy				memcpy

#define nim_i2c_read			i2c_read
#define nim_i2c_write			i2c_write
#define nim_i2c_write_read		i2c_write_read

#define div_u64(a,b)			a=(a/b)
//div_u64(ulHigh, pObj->sConfig.uSamplingClock); 

void 							nim_comm_delay(UINT32 us);



#define NIM_MUTEX_ENTER(priv)  	OS_LockMutex(priv->i2c_mutex, OSAL_WAIT_FOREVER_TIME)
#define NIM_MUTEX_LEAVE(priv) 	OS_UnlockMutex(priv->i2c_mutex)








struct nim_tda10025_private
{

	/* struct for QAM Configuration */
	struct   QAM_TUNER_CONFIG_DATA tuner_config_data;

	/* Tuner Initialization Function */
	INT32 (*nim_Tuner_Init)(UINT32 * ptrTun_id, struct QAM_TUNER_CONFIG_EXT * ptrTuner_Config);

	/* Tuner Parameter Configuration Function */
	INT32 (*nim_Tuner_Control)(UINT32 Tun_id, UINT32 freq, UINT32 sym, UINT8 AGC_Time_Const, UINT8 _i2c_cmd);//since there will no bandwidth demand, so pass "sym" for later use.

	/* Get Tuner Status Function */
	INT32 (*nim_Tuner_Status)(UINT32 Tun_id, UINT8 *lock);

	/* Open  Function*/
	INT32 (*nim_Tuner_Open)(UINT32 Tun_id);

	/* Close Function. */
	INT32 (*nim_Tuner_Close)(UINT32 Tun_id);
	/* END */

	/* Extension struct for Tuner Configuration */
	struct QAM_TUNER_CONFIG_EXT tuner_config_ext;
	
	UINT32 tuner_id;
	UINT32 qam_mode;
	
	UINT32 i2c_type_id;
	
	UINT32 i2c_mutex;
};

typedef struct NIM_Channel_Change    NIM_CHANNEL_CHANGE;

INT32 	nim_tda10025_dev_init(struct nim_device *dev);
INT32 	nim_tda10025_get_lock(struct nim_device *dev, UINT8 *lock );
INT32 	nim_tda10025_get_freq(struct nim_device *dev, UINT32 *freq );
INT32 	nim_tda10025_get_qam(struct nim_device *dev, UINT8 *qam_order );
INT32 	nim_tda10025_get_SNR(struct nim_device *dev, UINT8 *snr );
INT32 	nim_tda10025_get_symbolrate(struct nim_device *dev, UINT32 *sym_rate );
INT32 	nim_tda10025_get_BER(struct nim_device *dev, UINT32 *err_count );
INT32 	nim_tda10025_get_AGC(struct nim_device *dev, UINT8 *agc );
INT32 	nim_tda10025_channel_change(struct nim_device *dev, NIM_CHANNEL_CHANGE *pstChl_Change );
INT32 	nim_tda10025_I2C_switch( BOOL bOn );
INT32 	nim_tda10025_enter_standby(struct nim_device *dev);

INT32 	nim_tda10025_attach(struct QAM_TUNER_CONFIG_API * ptrQAM_Tuner);



#endif

